from path import Path
from core.registrar import register_app
from conf.config import app_config
from loguru import logger
import uvicorn

app = register_app()

if __name__ == '__main__':
    try:
        logger.info(f"############### 当前运行环境为 {app_config.APP_NAME} {app_config.APP_ENV} ###################")
        uvicorn.run(
            app=f'{Path(__file__).stem}:app',
            host=app_config.UVICORN_HOST,
            port=app_config.UVICORN_PORT,
            reload=app_config.UVICORN_RELOAD,
        )
    except Exception as e:
        logger.error(f'Failed to start: {e}')
